#include "sms.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>

#define TEACHER_STYLE_LAYOUT_NAME "layout-teacher-style"

typedef enum _LISTVIEW_POSITION_ID{
	LISTVIEW_POSITION_ID_LEFT,
	LISTVIEW_POSITION_ID_RIGHT,
	LISTVIEW_POSITION_ID_COUNT
}LISTVIEW_POSITION_ID;


typedef struct _TEACHER_STYLE_LAYOUT{
	GooCanvasItem *bg;
	GooCanvasItem *progress_bar;
	GooCanvasItem *arrow;
	GooCanvasItem *icon;
	GooCanvasItem *icon_text;
	ListView *list[LISTVIEW_POSITION_ID_COUNT];
	IconListView *iconlistview;

	int list_left_cur;
	int list_left_count;
	int list_right_cur;
	int list_right_count;

	gboolean in_left;
	gboolean in_right;

	GooCanvasItem *text;
	Downloader *downloader;
}Teacher_Style_Layout;

gboolean wait = FALSE;//this is a tag for all listview load finish


static gboolean teacher_style_layout_load_icon_text_view (xmlNode *a_node, Layout *layout, IconListView *ilv, gboolean useThemePic) {
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	GdkPixbuf *pixbuf_itv_bg, *pixbuf_itv_fg, *pixbuf_icon;
	gdouble view_x, view_y,
	        icon_x, icon_y,
	        text_x, text_y, text_w;
	xmlChar * val;
    xmlNode *cur_node = NULL;
	xmlNode *child_node = NULL;

	int view_id, total_icon_num;
	char pic[256];
	SMS *sms = layout->sms;

	IconTextView *icontextview;
	IconTextView **icontextlist = NULL;

	if (!useThemePic) {
		if(!a_node)
			return FALSE;
		for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
			if (cur_node->type == XML_ELEMENT_NODE) {
				if (strcmp(cur_node->name, "icon-text-views")==0) {

					/*load icon-text-view bg*/
					val = xmlGetProp (cur_node,(xmlChar*)"bg_pic");
					sprintf(pic, "%s/%s/layout/%s/%s", SMS_RESOURCE_DIR, "default"/*theme*/, layout->name, val);
   				    pixbuf_itv_bg = gdk_pixbuf_new_from_file(pic, NULL);
   				    /*load icon-text-view fg*/
					val = xmlGetProp (cur_node, (xmlChar*)"fg_pic");
					sprintf(pic, "%s/%s/layout/%s/%s", SMS_RESOURCE_DIR, "default"/*theme*/, layout->name, val);
					pixbuf_itv_fg = gdk_pixbuf_new_from_file(pic, NULL);

					total_icon_num = sms_get_xml_int (cur_node, (xmlChar*)"total_icon_num", 0);
		        }
			}
		}
	}

	icontextlist = (IconTextView**)g_malloc0(sizeof(IconTextView*)*total_icon_num + 1);

	//traversal the child node to get the icon_text_view resource path
	for (child_node = a_node->children; child_node; child_node = child_node->next) {
		if (child_node->type == XML_ELEMENT_NODE) {
			if (strcmp(child_node->name, "icon-text")==0) {
				view_id = sms_get_xml_int (child_node, (xmlChar*)"id", 0);
				view_x = sms_get_xml_int (child_node, (xmlChar*)"x", 0);
			    view_y = sms_get_xml_int (child_node, (xmlChar*)"y", 0);
				icon_x = sms_get_xml_double (child_node, (xmlChar*)"icon_x", 0);
				icon_y = sms_get_xml_double (child_node, (xmlChar*)"icon_y", 0);
				/*load the icon pic*/
				val = xmlGetProp (child_node, (xmlChar*)"icon_pic");
				sprintf(pic, "%s/%s/layout/%s/%s", SMS_RESOURCE_DIR, "default"/*theme*/, layout->name, val);
				pixbuf_icon = gdk_pixbuf_new_from_file(pic, NULL);

				text_x = sms_get_xml_double (child_node, (xmlChar*)"text_x", 0);
				text_y = sms_get_xml_double (child_node, (xmlChar*)"text_y", 0);
				text_w = sms_get_xml_double (child_node, (xmlChar*)"text_w", 0);
				/*load the text*/
				val = xmlGetProp (child_node, (xmlChar*)"text");
				printf("icon_x: %f icon_y: %f text_x: %f text_y: %f\n pic: %s text: %s\n",
						icon_x, icon_y, text_x, text_y, pic, val);

				icontextlist[view_id] = iconlist_view_create_icontextview(ilv, view_x, view_y,
						                                                       pixbuf_itv_bg, pixbuf_itv_fg, pixbuf_icon,
						                                                       icon_x, icon_y,
						                                                       text_x, text_y, text_w, val,
						                                                       sms->theme, view_id);
				iconlist_view_set_icontextlist(ilv, icontextlist);
				//icontext_view_set_view_background_pic(teacher_style_layout->icontextview, pixbuf_itv_bg);
			}
		}
	}
	//icontext_view_show(teacher_style_layout->icontextview);
}

static gboolean teacher_style_layout_load_bg(xmlNode *a_node, Layout *layout)
{
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	GdkPixbuf*  pixbuf;
	xmlChar * val;
	char pic[256];

	if(teacher_style_layout->bg||!a_node)
		return FALSE;

	val = xmlGetProp (a_node,(xmlChar*)"pic");
	if(!val)
		return FALSE;

	sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
	printf("pic=%s\n" , pic);
	pixbuf=sms_load_pic(pic,800,480);
	if(!pixbuf)
		return FALSE;

	teacher_style_layout->bg=goo_canvas_image_new (layout->cavas, pixbuf, 0, 0,NULL);

	//GooCanvasItem *wave ,*seaweed1 ,*seaweed2 ,*seaweed3 ,*ship ,*lan ,*cloud;

	/*sprintf(pic ,"%s/%s/layout/%s/%s" ,SMS_RESOURCE_DIR ,"default"
	  ,layout->name,"Clouds.png");
	  GdkPixbuf  *pixbuf_cloud=gdk_pixbuf_new_from_file(pic ,NULL);
	  cloud = goo_canvas_image_new(layout->cavas ,pixbuf_cloud ,0 ,0 ,NULL);
	  goo_canvas_item_set_simple_transform(cloud ,84 ,40 ,1 ,0);*/
	printf("finish func %s\n" ,__FUNCTION__);

	return TRUE;

}

static gboolean teacher_style_layout_load_left_list(xmlNode *a_node, gdouble x, gdouble y, GdkPixbuf *pix_list_bg, Layout *layout) {
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	GdkPixbuf *pix_list_item_icon, *pix_list_item_fg, *pix_list_item_bg,
			  *pix_down_btn, *pix_up_btn;
	xmlChar * val;
	SMS *sms = layout->sms;
	char *buf[20];
	char pic[256];
	int buf_num = 0;
	Node *n = NULL;
	int i;
	//Theme *theme;

	xmlNode *cur_node = NULL;
	if(!a_node)
		return FALSE;
	for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
		if (cur_node->type == XML_ELEMENT_NODE) {
			if (strcmp(cur_node->name,"list-icon")==0) {
				val = xmlGetProp (cur_node,(xmlChar*)"pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);

				pix_list_item_icon = gdk_pixbuf_new_from_file(pic ,NULL);
			} else if (strcmp(cur_node->name,"list-fg")==0) {
				val = xmlGetProp (cur_node,(xmlChar*)"pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				pix_list_item_fg = gdk_pixbuf_new_from_file(pic ,NULL);
			} else if (strcmp(cur_node->name,"list-bg")==0) {
				val = xmlGetProp (cur_node,(xmlChar*)"pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				pix_list_item_bg = gdk_pixbuf_new_from_file(pic ,NULL);
			} /*else if (strcmp(cur_node->name,"down-btn")==0) {
				val = xmlGetProp (cur_node,(xmlChar*)"pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default",layout->name,val);
				pix_down_btn = gdk_pixbuf_new_from_file(pic ,NULL);
				} else if (strcmp(cur_node->name,"up-btn")==0) {
				val = xmlGetProp (cur_node,(xmlChar*)"pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default",layout->name,val);
				pix_up_btn = gdk_pixbuf_new_from_file(pic ,NULL);
				}*/ else if (strcmp(cur_node->name,"text")==0) {
					val = xmlGetProp (cur_node,(xmlChar*) "value");
					printf("text%d: %s\n", buf_num, val);
					buf[buf_num] = val;
					++buf_num;
				}
		}
	}

	//printf("x=%f, y=%f\n", x, y);
	//theme = listview_change_theme(sms->theme, pix_list_bg,	pix_list_bg, pix_list_item_fg, NULL);
	teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT] = listview_new (layout->cavas, x, y, sms->theme, LISTVIEW_ICON);
	/*teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT] = listview_no_frame_bg_new(layout->cavas, x, y,
			pix_list_item_fg, pix_list_item_icon,
			pix_list_bg,
			sms->theme, LISTVIEW_ICON);*/

	printf("pass listview_new\n");
	for(i=0; i<buf_num; i++) {
		n = listview_item_create (pix_list_item_icon, pix_list_item_icon, buf[i], NULL);
		listview_add_item (teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT], n);
	}
	listview_show(teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT]);
	teacher_style_layout->list_left_count= buf_num - 1;

	printf("finish func %s\n" ,__FUNCTION__);
	return TRUE;
}

static gboolean teacher_style_layout_load_right_list(xmlNode *a_node, Layout *layout) {
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	xmlChar * val;
	char pic[256];
	SMS *sms = layout->sms;

	xmlNode *cur_node = NULL;
	xmlNode *icon_text_node = NULL;
	IconTextView **icontextlist = NULL;
	IconListView *ilv = NULL;

	int total_icon_view_num;
	gdouble icon_w, icon_h,
	        icon_list_view_x, icon_list_view_y,
	        icon_list_view_h_margins, icon_list_view_w_margins,
	        icon_list_view_h_spacing, icon_list_view_w_spacing;

	GdkPixbuf *icon_list_view_bg, *icon_list_view_showarea, *icon_view;

	if(!a_node)
		return FALSE;
	for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
		if (cur_node->type == XML_ELEMENT_NODE) {
			if(strcmp(cur_node->name, "icon-list-view")==0) {
				icon_list_view_x = sms_get_xml_double (cur_node, (xmlChar*)"x", 0);
				icon_list_view_y = sms_get_xml_double (cur_node, (xmlChar*)"y", 0);
				icon_list_view_h_margins = sms_get_xml_double (cur_node, (xmlChar*)"h_margins", 0);
				icon_list_view_w_margins = sms_get_xml_double (cur_node, (xmlChar*)"w_margins", 0);
				icon_list_view_h_spacing = sms_get_xml_double (cur_node, (xmlChar*)"h_spacing", 0);
				icon_list_view_w_spacing = sms_get_xml_double (cur_node, (xmlChar*)"w_spacing", 0);

				val = xmlGetProp (cur_node, (xmlChar*)"bg");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				icon_list_view_bg = gdk_pixbuf_new_from_file(pic ,NULL);

				val = xmlGetProp (cur_node, (xmlChar*)"showarea");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				icon_list_view_showarea = gdk_pixbuf_new_from_file(pic ,NULL);
			}
		}
	}


	for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
		if (cur_node->type == XML_ELEMENT_NODE) {
			if(strcmp(cur_node->name, "icon-text-views")==0) {
				total_icon_view_num = sms_get_xml_int (cur_node, (xmlChar*)"total_icon_num", 0);

				val = xmlGetProp (cur_node, (xmlChar*)"bg_pic");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				icon_view = gdk_pixbuf_new_from_file(pic ,NULL);
				icon_w = gdk_pixbuf_get_width(icon_view);
				icon_h = gdk_pixbuf_get_height(icon_view);
				icon_text_node = cur_node;
			}
		}
	}

	if(!icon_text_node)
		return FALSE;


	ilv = iconlist_view_new(layout->cavas, icon_list_view_x, icon_list_view_y,
			                         icon_list_view_bg, icon_list_view_showarea,
			                         icon_w, icon_h,
			                         icon_list_view_h_margins, icon_list_view_w_margins,
			                         icon_list_view_h_spacing, icon_list_view_w_spacing,
			                         total_icon_view_num,
			                         sms->theme);

    teacher_style_layout_load_icon_text_view (icon_text_node, layout, ilv, FALSE);
	return TRUE;
}

static gboolean teacher_style_layout_travel_xml(xmlNode *a_node,Layout *layout) {
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	SMS *sms=layout->sms;
	xmlChar *val;
	char pic[256];
	xmlNode *cur_node = NULL;
	xmlNode *bg_node = NULL;
	xmlNode *animate_node = NULL;
	xmlNode *title_node = NULL;
	xmlNode *left_list_node = NULL;
	xmlNode *right_list_node = NULL;

	gdouble left_list_x, left_list_y;
	GdkPixbuf *left_list_bg;

	for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
		if (cur_node->type == XML_ELEMENT_NODE) {
			if(strcmp(cur_node->name,"bg")==0)
				bg_node=cur_node;
			else if(strcmp(cur_node->name,"title")==0)
				title_node = cur_node;
			else if(strcmp(cur_node->name,"left-list")==0) {
				left_list_node = cur_node;
				left_list_x = sms_get_xml_double (left_list_node, (xmlChar*)"x", 0);
				left_list_y = sms_get_xml_double (left_list_node, (xmlChar*)"y", 0);

				val = xmlGetProp (cur_node,(xmlChar*)"bg");
				sprintf(pic,"%s/%s/layout/%s/%s",SMS_RESOURCE_DIR,"default"/*theme*/,layout->name,val);
				left_list_bg = gdk_pixbuf_new_from_file(pic ,NULL);
			} else if(strcmp(cur_node->name,"right-list")==0)
				right_list_node = cur_node;
			else if(strcmp(cur_node->name,"animates")==0)
				animate_node = cur_node;
			/*else if(strcmp(cur_node->name,"images")==0){
			  if(!ip_radio_load_image(cur_node->children,layout))
			  return FALSE;
			  }else if(strcmp(cur_node->name,"texts")==0){
			  if(!ip_radio_load_text(cur_node->children,layout))
			  return FALSE;
			  }*/
		}
	}

	if(!bg_node||!animate_node||!title_node||!left_list_node||!right_list_node)
		return FALSE;

	teacher_style_layout_load_bg(bg_node,layout);
	//teacher_style_layout_load_title(title_node->children, layout);
	teacher_style_layout_load_left_list(left_list_node->children, left_list_x, left_list_y, left_list_bg, layout);
	teacher_style_layout_load_right_list(right_list_node, layout);
	//teacher_style_layout_load_animates (animate_node->children, layout);

	printf("finish func %s\n" ,__FUNCTION__);

	return TRUE;
}

static gboolean teacher_style_layout_load_config(Layout *layout){
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;
	SMS *sms=layout->sms;

	gboolean ret=FALSE;
	xmlDoc *doc = NULL;
	xmlNode *root_element = NULL;

	char conf[256];

	sprintf(conf,"%s/%s/layout/%s/layout.xml",SMS_RESOURCE_DIR, "default",layout->name);
	printf("conf: %s\n", conf);

	doc = xmlReadFile(conf, NULL, 0);

	if (doc == NULL) {
		fprintf(stderr,"error: could not parse file %s\n", conf);
		return ret;
	}

	root_element = xmlDocGetRootElement(doc);

	if(root_element){
		xmlNode *cur_node = NULL;
		for (cur_node = root_element; cur_node; cur_node = cur_node->next) {
			if (cur_node->type == XML_ELEMENT_NODE) {
				ret=TRUE;
				break;
			}
		}
		if(ret)
			ret=teacher_style_layout_travel_xml(cur_node->children,layout);
	}

	xmlFreeDoc(doc);
	xmlCleanupParser();
	wait=TRUE;
	printf("finish func %s\n" ,__FUNCTION__);
	return ret;
}

gboolean teacher_style_layout_init(Layout *layout,gpointer data){
	printf("start func %s\n" ,__FUNCTION__);
	SMS *sms=layout->sms;
	GdkPixbuf *pixbuf;
	Teacher_Style_Layout *teacher_style_layout=(Teacher_Style_Layout *)g_malloc0(sizeof(Teacher_Style_Layout)+1);

	layout->private=(void *)teacher_style_layout;

	layout->cavas = goo_canvas_group_new(layout->parent,NULL);

	if(!teacher_style_layout_load_config(layout)){
		fprintf(stderr,"%s:load config err\n",__FUNCTION__);
		return FALSE;//exit(-1);
	}

	/*if(!ip_radio_create_left_list(layout,ip_radio_pixbuf[IP_RADIO_IMAGE_LEFT_BG],
	  ip_radio_pixbuf[IP_RADIO_IMAGE_LEFT_BG])){
	  fprintf(stderr,"%s:lcreate_left_list err\n",__FUNCTION__);
	  return FALSE;//exit(-1);
	  }
	  if(!ip_radio_create_arrow(layout)){
	  fprintf(stderr,"%s:create_arrow err\n",__FUNCTION__);
	  return FALSE;//exit(-1);
	  }
	  if(!ip_radio_create_center_list(layout)){
	  fprintf(stderr,"%s:create_center_list err\n",__FUNCTION__);
	  return FALSE;//exit(-1);
	  }*/
	teacher_style_layout->in_left=TRUE;
	//ip_radio->in_center=FALSE;
	//ip_radio->in_right=FALSE;

	printf("finish func %s\n" ,__FUNCTION__);
	return TRUE;
}

gboolean teacher_style_layout_clear(Layout *layout,gpointer data){

	return TRUE;
}

gboolean teacher_style_layout_press(Layout * layout,GdkEventKey *event) {
	printf("start func %s\n" ,__FUNCTION__);
	Teacher_Style_Layout *teacher_style_layout = layout->private;

	if(wait) {
		if(event->keyval==GDK_Up){
			if(teacher_style_layout->in_left){
				if(teacher_style_layout->list_left_cur > 0){
					teacher_style_layout->list_left_cur--;
					listview_translate(teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT],-1);
					/*listview_set_to(ip_radio->list[LISTVIEW_POSITION_ID_CENTER],
							tmp[ip_radio->list_left_cur]+1);
					ip_radio->list_center_cur=tmp[ip_radio->list_left_cur]+1;
					listview_highlight_translate(ip_radio->list[LISTVIEW_POSITION_ID_CENTER],
							0 - ip_radio->list[LISTVIEW_POSITION_ID_CENTER]->view_cur);*/

					///////////////////////////////PROGRESS///////////////////////////////////
					/*goo_canvas_item_animate (ip_radio->arrow,0,
							ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->view_cur*30,1,
							0, TRUE,20,10,GOO_CANVAS_ANIMATE_FREEZE);
					if(ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur<=0){
						//up0,down1
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_DOWN_BG],NULL);
					}else if((ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur+ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur)>=ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_count){
						//up1,down0
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_UP_BG],NULL);
					}else if((ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur<=0)&&(ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_count < ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->view_count)){
						//up0,down0
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_FG],NULL);
					}else{
						//up1,down1
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_CENTER],NULL);
					}*/
					//ip_radio_right_double_create(layout);
				}
			}else if(teacher_style_layout->in_right){
				if(teacher_style_layout->list_right_cur > 0){
					teacher_style_layout->list_right_cur--;
					listview_translate(teacher_style_layout->list[LISTVIEW_POSITION_ID_RIGHT],-1);
				}
			}
			return TRUE;
		}else if(event->keyval==GDK_Down){
			if(teacher_style_layout->in_left){
				if(teacher_style_layout->list_left_cur < teacher_style_layout->list_left_count){
					teacher_style_layout->list_left_cur++;
					listview_translate(teacher_style_layout->list[LISTVIEW_POSITION_ID_LEFT],1);
					/*listview_set_to(ip_radio->list[LISTVIEW_POSITION_ID_CENTER],
							tmp[ip_radio->list_left_cur]+1);
					ip_radio->list_center_cur=tmp[ip_radio->list_left_cur]+1;
					listview_highlight_translate(ip_radio->list[LISTVIEW_POSITION_ID_CENTER],
							0 - ip_radio->list[LISTVIEW_POSITION_ID_CENTER]->view_cur);*/
					///////////////////////////////PROGRESS///////////////////////////////////
					/*goo_canvas_item_animate (ip_radio->arrow,0,
							ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->view_cur*30,1,
							0, TRUE,20,10,GOO_CANVAS_ANIMATE_FREEZE);
					if(ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur<=0){
						//up0,down1
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_DOWN_BG],NULL);
					}else if((ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur+ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur)>=ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_count){
						//up1,down0
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_UP_BG],NULL);
					}else if((ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_cur<=0)&&(ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->list_count < ip_radio->list[LISTVIEW_POSITION_ID_LEFT]->view_count)){
						//up0,down0
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_FG],NULL);
					}else{
						//up1,down1
						g_object_set(ip_radio->progress_bar,"pixbuf",
								ip_radio_pixbuf[IP_RADIO_IMAGE_PROGRESS_CENTER],NULL);
					}*/
				}
			}else if(teacher_style_layout->in_right){
				if(teacher_style_layout->list_right_cur < teacher_style_layout->list_right_count){
					teacher_style_layout->list_right_cur++;
					listview_translate(teacher_style_layout->list[LISTVIEW_POSITION_ID_RIGHT],1);
				}
			}
			return TRUE;
		}
	}

	return FALSE;
}

Layout *teacher_style_layout_new(GooCanvasItem * parent,gpointer sms){
	Layout *layout=layout_new(parent,LAYOUT_TYPE_WIN, LAYOUT_WIN_TEACHER_STYLE, TEACHER_STYLE_LAYOUT_NAME, sms);
	layout_set_func(layout,"init",teacher_style_layout_init);
	layout_set_func(layout,"clear", teacher_style_layout_clear);
	layout_set_func(layout,"key-press", teacher_style_layout_press);

	return layout;
}
